/**************************************************************************
 *
 *        Copyright (c) 2007-2008 by Sunplus mMedia Inc., Ltd.
 *
 *  This software is copyrighted by and is the property of Sunplus
 *  mMedia Inc., Ltd. All rights are reserved by Sunplus mMedia
 *  Inc., Ltd. This software may only be used in accordance with the
 *  corresponding license agreement. Any unauthorized use, duplication,
 *  distribution, or disclosure of this software is expressly forbidden.
 *
 *  This Copyright notice MUST not be removed or modified without prior
 *  written consent of Sunplus mMedia Inc., Ltd.
 *
 *  Sunplus mMedia Inc., Ltd. reserves the right to modify this
 *  software without notice.
 *
 *  Sunplus mMedia Inc., Ltd.
 *  19-1, Innovation First Road, Science-Based Industrial Park,
 *  Hsin-Chu, Taiwan, R.O.C.
 *
 **************************************************************************/
/**
 * @file		disp_api.h
 * @brief		display module header file.
 * @author		Ted Chiu, Matt Wang
 * @since		2008-03-14
 * @date		2009-02-20
 */
#ifndef __DISP_API_H__
#define __DISP_API_H__

/**************************************************************************
 *                              C O N S T A N T S
 **************************************************************************/
#define DISP_DEVICE_TOT  3

typedef enum {
	DISP_PARA_CLK_ENABLE,
	DISP_PARA_CLK_CFG,
	DISP_PARA_GLOB_ENABLE,
	DISP_PARA_IMG_LAYER_ENABLE,
	DISP_PARA_GLOB_BLEND_FACTOR,
	DISP_PARA_IMG_LAYER_FLIP,
	DISP_PARA_IMG_LAYER_MONOCHROME_ENABLE,
	DISP_PARA_OSD_LAYER_ENABLE,
	DISP_PARA_BG_COLOR,
	DISP_PARA_DEVICE_TYPE,
	DISP_PARA_DEVICE_TOTAL_REGION,
	DISP_PARA_DEVICE_ACTIVE_REGION,
	DISP_PARA_OSD_WINDOW_OFFSET,
	DISP_PARA_OSD_WINDOW_SCROLL,
	DISP_PARA_OSD_WINDOW_SCALE_FACTOR,
	DISP_PARA_OSD_WINDOW_DIMENSION,
	DISP_PARA_OSD_FONT_SIZE,
	DISP_PARA_OSD_CHAR_INDEX,
	DISP_PARA_OSD_CHAR_ATTRIBUTE,
	DISP_PARA_OSD_BLINK_SPEED,
	DISP_PARA_OSD_BLEND_FACTOR,
	DISP_PARA_OSD_LOW_PASS_FILTER_ENABLE,
	DISP_PARA_SELECT_WINDOW_ENABLE,
	DISP_PARA_SELECT_WINDOW_REGION,
	DISP_PARA_SELECT_WINDOW_FRAME_WIDTH,
	DISP_PARA_SELECT_WINDOW_COLOR,
	DISP_PARA_INTERLACE_CFG,
	DISP_PARA_LCD_DITHER_ENABLE,
	DISP_PARA_UPS051_PIXEL_SHIFT_CFG,
	DISP_PARA_UPS051_LIGHTVIEW_ENABLE,
	DISP_PARA_UPS052_RGB_ONLY_ENABLE,
	DISP_PARA_UPS052_HSD_DELAY_CFG,
	DISP_PARA_UPS_CLK_PHASE,
	DISP_PARA_UPS_LAYOUT_MODE,
	DISP_PARA_UPS_COLOR_FILTER_CFG,
	DISP_PARA_CCIR_OUTPUT_SEQUENCE_CFG,
	DISP_PARA_GAMMA_ENABLE,
	DISP_PARA_TV_DAC_POWER_ENABLE,
	DISP_PARA_TV_SATURATION,
	DISP_PARA_TV_HUE,
	DISP_PARA_LCM_CMD_BUS_TYPE,
	DISP_PARA_LCM_CMD_BIT_WIDTH,
	DISP_PARA_LCM_CMD_PULSE_WIDTH,
	DISP_PARA_LCM_CMD_ACTIVE_LEVEL,
	DISP_PARA_LCM_DATA_FORMAT,
	DISP_PARA_LCM_RGB666_PACK_ENABLE,
	DISP_PARA_LCM_RGB666_FORMAT_10_ENABLE,
	DISP_PARA_LCM_PIXEL_ALIGN,
	DISP_PARA_LCM_COLOR_PACKAGE,
	DISP_PARA_LCM_SWITCH_G_ENABLE,
	DISP_PARA_LCM_CHANGE_RB_ENABLE,
	DISP_PARA_LCM_ONE_HALF_PIXEL_ENABLE,
	DISP_PARA_LCM_DITHER_ENABLE,
	DISP_PARA_MAX_ID,
} dispParaId_e;  /* plz keep sync to HAL_DispParaId_e. */

typedef enum {
	DISP_CLK_SRC_SYSPLL96M = 0,
	DISP_CLK_SRC_XTAL27M   = 1,
} dispClkSrc_e;  /* plz keep sync to HAL_DispClkSrc_e. */

typedef enum {
	DISP_DEVICE_TYPE_COMPOSITE_NTSC  = 0x00,
	DISP_DEVICE_TYPE_COMPOSITE_PAL   = 0x01,
	DISP_DEVICE_TYPE_CCIR601_NTSC_8  = 0x04,
	DISP_DEVICE_TYPE_CCIR601_PAL_8   = 0x05,
	DISP_DEVICE_TYPE_CCIR601_NTSC_16 = 0x06,
	DISP_DEVICE_TYPE_CCIR601_PAL_16  = 0x07,
	DISP_DEVICE_TYPE_UPS051          = 0x08,
	DISP_DEVICE_TYPE_UPS052          = 0x09,
	DISP_DEVICE_TYPE_LCM             = 0x0A,
	DISP_DEVICE_TYPE_VGA_TFT         = 0x0C,
	DISP_DEVICE_TYPE_USER_CCIR601_8  = 0x0E,
	DISP_DEVICE_TYPE_USER_CCIR601_16 = 0x0F,
} dispDeviceType_e;  /* plz keep sync to HAL_DispDeviceType_e. */

typedef enum {
	DISP_PROGRESSIVE = 0x01,
	DISP_INTERLACE   = 0x02,
} dispInterlaceCfg_e;  /* plz keep sync to HAL_DispInterlaceCfg_e. */

typedef enum {
	DISP_PIXEL_SHIFT_DISABLE = 0x00,
	DISP_PIXEL_SHIFT_ODD     = 0x10,
	DISP_PIXEL_SHIFT_EVEN    = 0x30,
} dispUps051PixelShiftCfg_e;  /* plz keep sync to HAL_DispUps051PixelShiftCfg_e. */

typedef enum {
	DISP_UPS052_HSD_NO_DELAY = (1 << 0),
	DISP_UPS052_HSD_DELAY_3T = (0 << 0),
} dispUps052HsdDelayCfg_e;  /* plz keep sync to HAL_DispUps052HsdDelayCfg_e. */

typedef enum {
	DISP_UPS_LAYOUT_MODE_DISABLE       = 0x00,
	DISP_UPS_LAYOUT_MODE_ODD_DELAY_1T  = 0x08,
	DISP_UPS_LAYOUT_MODE_EVEN_DELAY_1T = 0x0C,
} dispUpsLayoutMode_e;  /* plz keep sync to HAL_DispUpsLayoutMode_e. */

typedef enum {
 	DISP_UPS051_ODD_RGB = (0 << 0),
	DISP_UPS051_ODD_GBR = (1 << 0),
	DISP_UPS051_ODD_BRG = (2 << 0),
	DISP_UPS051_ODD_BGR = (3 << 0),
	DISP_UPS051_ODD_RBG = (4 << 0),
	DISP_UPS051_ODD_GRB = (5 << 0),

 	DISP_UPS052_ODD_RGB = (0 << 0),
	DISP_UPS052_ODD_GBR = (1 << 0),
	DISP_UPS052_ODD_BRG = (2 << 0),
	DISP_UPS052_ODD_RBG = (3 << 0),
	DISP_UPS052_ODD_BGR = (4 << 0),
	DISP_UPS052_ODD_GRB = (5 << 0),
} dispUpsOddColorFilter_e;  /* plz keep sync to HAL_DispUpsOddColorFilter_e. */

typedef enum {
 	DISP_UPS051_EVEN_BRG = (0 << 3),
 	DISP_UPS051_EVEN_RGB = (1 << 3),
	DISP_UPS051_EVEN_GBR = (2 << 3),
	DISP_UPS051_EVEN_GRB = (3 << 3),
	DISP_UPS051_EVEN_BGR = (4 << 3),
	DISP_UPS051_EVEN_RBG = (5 << 3),

 	DISP_UPS052_EVEN_RGB = (0 << 3),
	DISP_UPS052_EVEN_GBR = (1 << 3),
	DISP_UPS052_EVEN_BRG = (2 << 3),
	DISP_UPS052_EVEN_RBG = (3 << 3),
	DISP_UPS052_EVEN_BGR = (4 << 3),
	DISP_UPS052_EVEN_GRB = (5 << 3),
} dispUpsEvenColorFilter_e;  /* plz keep sync to HAL_DispUpsEvenColorFilter_e. */

typedef enum {
	DISP_CCIR_YCRYCB = (0 << 0),
	DISP_CCIR_CRYCBY = (1 << 0),
	DISP_CCIR_YCBYCR = (2 << 0),
	DISP_CCIR_CBYCRY = (3 << 0),
} dispCcirOutputSeqCfg_e;  /* plz keep sync to HAL_DispCcirOutputSeqCfg_e. */

typedef enum {
	DISP_LCM_CMD_BUS_I80 = (0 << 3),
	DISP_LCM_CMD_BUS_M68 = (1 << 3),
} dispLcmCommandBusType_e;  /* plz keep sync to HAL_DispLcmCommandBusType_e. */

typedef enum {
	DISP_LCM_CMD_8_9_BIT   = (0 << 0),
	DISP_LCM_CMD_16_18_BIT = (1 << 0),
} dispLcmCommandBitWidth_e;  /* plz keep sync to HAL_DispLcmCommandBitWidth_e. */

typedef enum {
	DISP_LCM_DATA_FMT_RGB666 = (0 << 0),
	DISP_LCM_DATA_FMT_RGB565 = (1 << 0),
	DISP_LCM_DATA_FMT_RGB444 = (2 << 0),
	DISP_LCM_DATA_FMT_RGB332 = (3 << 0),
} dispLcmDataFormat_e;  /* plz keep sync to HAL_DispLcmDataFormat_e. */

typedef enum {
	DISP_LCM_PIXEL_ALIGN_NONE = (0 << 0),
	DISP_LCM_PIXEL_ALIGN_BIG  = (1 << 0),
	DISP_LCM_PIXEL_ALIGN_MID  = (2 << 0),
	DISP_LCM_PIXEL_ALIGN_BOTH = (3 << 0),
} dispLcmPixelAlign_e;  /* plz keep sync to HAL_DispLcmPixelAlign_e. */

typedef enum {
	DISP_LCM_COLOR_PACKAGE_RGB  = (1 << 0),
	DISP_LCM_COLOR_PACKAGE_BGR  = (0 << 0),
} dispLcmColorPackage_e;  /* plz keep sync to HAL_DispLcmColorPackage_e. */

typedef enum {
	DISP_WAIT_HVALID = (1 << 0),
	DISP_WAIT_HSYNC  = (1 << 1),
	DISP_WAIT_VVALID = (1 << 2),
	DISP_WAIT_VSYNC  = (1 << 3),
} dispWaitSource_e;  /* plz keep sync to HAL_DispWaitSource_e. */

typedef enum {
	DISP_WAIT_FALLING = 0,
	DISP_WAIT_RISING  = 1,
	DISP_WAIT_HIGH    = 2,
	DISP_WAIT_LOW     = 3,
} dispWaitMode_e;  /* plz keep sync to HAL_DispWaitMode_e. */

#define DISP_LCM_CMD_INST  0x01000000L
#define DISP_LCM_CMD_PARA  0x02000000L
#define DISP_LCM_CMD_WAIT  0x03000000L
#define DISP_LCM_CMD_STOP  0x04000000L

/**************************************************************************
 *                              D A T A   T Y P E S
 **************************************************************************/
typedef struct {
	UINT16 width;
	UINT16 height;
	UINT16 xoff;
	UINT16 yoff;
	UINT16 aspectRatioX;
	UINT16 aspectRatioY;
} dispCapabDesc_t;

typedef UINT8 *(code *pfOperatingDispDevNameGet_t)(void);
typedef void (code *pfOperatingDispCapabilityGet_t)(dispCapabDesc_t *pcapabDesc);
typedef void (code *pfOperatingDispPowerOn_t)(void);
typedef void (code *pfOperatingDispPowerOff_t)(void);

typedef struct {
	pfOperatingDispDevNameGet_t pfOpDevNameGet;
	pfOperatingDispCapabilityGet_t pfOpCapabilityGet;
	pfOperatingDispPowerOn_t pfOpPowerOn;
	pfOperatingDispPowerOff_t pfOpPowerOff;
} dispOperatingFunc_t;

/**************************************************************************
 *                  F U N C T I O N   D E C L A R A T I O N S
 **************************************************************************/
/* disp_enable.c */
void dispEn(UINT8 en);
void dispImgWinEn(UINT8 en);

/* disp_lcm.c */
UINT8 dispLcmCmdTableSend(UINT32 *cmdTbl);

/* disp_win.c */
void dispPnlDimGet(UINT16 *dispH, UINT16 *dispW);
void dispPnlAspectRatioGet(UINT8 *ratX, UINT8 *ratY);

/* disp_misc.c */
void dispPbBufSet(UINT32 addr, UINT16 w, UINT16 h);

/* sp1k_disp_api.c */
void dispShow(UINT32 addr,UINT16 w,UINT16 h, UINT16 factor);

/* disp_logi.c */
UINT8 dispDevOpen(dispOperatingFunc_t *popFunc, UINT16 opFuncSize);
UINT8 dispDevActSet(UINT8 id);
UINT8 dispDevActGet(void);
UINT8 dispCapabilityGet(UINT8 id, dispCapabDesc_t *pcapabDesc);
UINT8 dispPowerOn(UINT8 id);
UINT8 dispPowerOff(UINT8 id);

/* disp_para.c */
UINT8 dispParaSet(UINT8 id, SINT16 para1, SINT16 para2, SINT16 para3, SINT16 para4, UINT8 upd);

/* disp_wait.c */
UINT8 dispSignalWait(UINT8 src, UINT8 mode);

#define dispOsdPaletteSet  HAL_DispOsdPaletteSet

#endif  /* __DISP_API_H__ */

